package com.zh.operation.service.impl;
import com.zh.common.service.FileService;
import com.zh.operation.dao.BasicInfoDao;
import com.zh.operation.domain.BasicInfoDO;
import com.zh.operation.service.BasicInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class BasicInfoServiceImpl implements BasicInfoService {
    @Autowired
    private BasicInfoDao basicInfoDao;

    private static final Logger logger = LoggerFactory.getLogger(BasicInfoService.class);
    @Override
    public BasicInfoDO get(String id){
        return basicInfoDao.get(id);
    }

    @Override
    public List<BasicInfoDO> list(Map<String, Object> map){
        return basicInfoDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map){
        return basicInfoDao.count(map);
    }

    @Override
    public int save(BasicInfoDO basicInfo){
        return basicInfoDao.save(basicInfo);
    }

    @Override
    public int update(BasicInfoDO basicInfo){
        return basicInfoDao.update(basicInfo);
    }

    @Override
    public int remove(Long id){
        return basicInfoDao.remove(id);
    }

    @Override
    public int batchRemove(Long[] ids){
        return basicInfoDao.batchRemove(ids);
    }

    @Override
    public List<BasicInfoDO> getAll(BasicInfoDO basicInfo) {
        return basicInfoDao.getAll(basicInfo);
    }
	/*@Override
	public Map<String, Object> updatePersonalImg(MultipartFile file, String avatar_data, Long userId) throws Exception {
		String fileName = file.getOriginalFilename();
		fileName = FileUtil.renameToUUID(fileName);
		FileDO sysFile = new FileDO(FileType.fileType(fileName), "/files/" + fileName, new Date());
		//获取图片后缀
		String prefix = fileName.substring((fileName.lastIndexOf(".")+1));
		String[] str=avatar_data.split(",");
		//获取截取的x坐标
		int x = (int)Math.floor(Double.parseDouble(str[0].split(":")[1]));
		//获取截取的y坐标
		int y = (int)Math.floor(Double.parseDouble(str[1].split(":")[1]));
		//获取截取的高度
		int h = (int)Math.floor(Double.parseDouble(str[2].split(":")[1]));
		//获取截取的宽度
		int w = (int)Math.floor(Double.parseDouble(str[3].split(":")[1]));
		//获取旋转的角度
		int r = Integer.parseInt(str[4].split(":")[1].replaceAll("}", ""));
		try {
			BufferedImage cutImage = ImageUtils.cutImage(file,x,y,w,h,prefix);
			BufferedImage rotateImage = ImageUtils.rotateImage(cutImage, r);
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			boolean flag = ImageIO.write(rotateImage, prefix, out);
			//转换后存入数据库
			byte[] b = out.toByteArray();

			FileUtil.uploadFile(b, bootConfig.getUploadPath(), fileName);

		} catch (Exception e) {
			throw  new Exception("图片裁剪错误！！");
		}
		Map<String, Object> result = new HashMap<>();
		if(sysFileService.save(sysFile)>0){
			BasicInfoDO basicInfoDO = new BasicInfoDO();
			basicInfoDO.setId(userId);
			basicInfoDO.setNusImg(sysFile.getId());
			if(basicInfoDao.update(basicInfoDO)>0){
				result.put("url",sysFile.getUrl());
			}
		}
		return result;
	}*/



    @Override
    public List<BasicInfoDO> getAll() {

        return basicInfoDao.getAll();
    }


}
